<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <style>
    .div {
      width: 100px;
      height: 100px;
    }
  </style>
</head>

<body>
  <div id = "app">
    <input type="text" v-model.number = "r"><br/>
    <input type="text" v-model.number = "g"><br/>
    <input type="text" v-model.number = "b">
    <div class="div" :style = "{backgroundColor:rgb}">{{rgb}}</div>
    <button @click = "show">按钮</button>
  </div>

  <script>
    const app = new Vue({
      el:"#app",
      data:{
        r:0,g:0,b:0
      },
      methods:{
        show(){
          console.log(this.rgb);
        }
      },
      computed:{
        rgb(){
          return `rgb(${this.r},${this.g},${this.b})`
        }
      }
    })
  </script>
  </div>
</body>
</html>